Technical Q&As
QD3D 72 - QD3D Is Not Thread-Safe (11-July-97)
Q
I am trying to do rendering in a cooperative thread while another thread is doing
something else. I thought I would yield from within a rendering loop, but it seems
the rendering loop gets executed only once no matter how lengthy the rendering is.
Could someone give me some suggestions?
A
The current version of QuickDraw 3D is not thread safe so I would not recommend that
you do this.
Also QuickDraw itself is not thread safe, so it would be dangerous to even have two
threads that do any drawing at all.
However, if you are doing QD3D stuff in one thread and no drawing in the other
thread, you could potentially get 3D to yield time by installing a view idle handler.
I haven't not tried this from a threaded application, but you may want to give it a go.
Here is a small snippet that shows how you'd define and install the view idle method:
TQ3Status MyIdleMethod( TQ3ViewObject view, const void *idleData)
;
TQ3Status MyIdleMethod( TQ3ViewObject view, const void *idleData)
{
TQ3Status returnResult = kQ3Success ;
/* do whatever you need to do here */
/*
* NOTE: don't do anything that is particulalry time consuming
* or your rendering will take forever!!
*/
return returnResult ;
}
...
/* install the idle proc defined earlier */
myStatus = Q3View_SetIdleMethod ( gDocument.fView, MyIdleMethod, NULL )
;
...
Note that you'll be called more often from the wireframe renderer than the interactive
renderer. Your mileage may vary so you'll need to play around with this stuff.
-- Scott Kuechle
Worldwide Developer Technical Support
Technical Q&As
Previous Question | Contents |
Next Question
To contact us, please use the Contact Us page.